package com.psa.system;

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.psa.tool.SystemStatus;
import com.wxw.BaseLibrary.component.ScaleImageView;
import net.duohuo.dhroid.ioc.InjectUtil;
import net.duohuo.dhroid.ioc.annotation.InjectView;

/**
 *
 * @author david
 * @date 2017-06-09
 */
public class ShowImageActivity extends BaseActivity{
    private ScaleImageView imageView;
    @InjectView(id = R.id.ll_image)
    private LinearLayout ll_image;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.pop_imageview_layout);
        InjectUtil.inject(this);
        btn_next.setVisibility(View.INVISIBLE);
        try {
            Intent intent = getIntent();
            String title = intent.getExtras().getString("title");
            ((TextView) findViewById(R.id.tv_head_title)).setText(title);
            imageView = new ScaleImageView(getApplicationContext());
            imageView.setImageBitmap(SystemStatus.currentBitmap);
            ll_image.addView(imageView, ll_image.getLayoutParams());
        } catch (Exception e) {
            SystemStatus.showMessage(this,e.toString() + ":" + e.getMessage());
        }
    }

    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.btn_back) {
            SystemStatus.currentBitmap = null;
        }
        super.onClick(view);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            SystemStatus.currentBitmap = null;
        }
        return super.onKeyDown(keyCode, event);
    }
}
